﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity;

namespace Husb.Data
{
    public class DBFactory<T> :Disposable, IDBFactory<T>
        where T : DBContext, new() 
    {
        private T dataContext;
        public T Get()
        {
            return dataContext ?? (dataContext = new T());
        }
        protected override void DisposeCore()
        {
            if (dataContext != null)
                dataContext.Dispose();
        }
    }
}
